package com.zgkxzx.java.mutilThread.dcl;

import java.util.Random;

/**
 * 创建者 zgkxzx
 * 日期   1/11/18
 * 描述
 */

/**
 * 通过JVM加载静态内部类的机制完美实现单例的同步问题
 */

public class Singleston2 {

    private int value;

    private Singleston2() {
        value = new Random().nextInt(100) + 5;
    }

    private static class SinglestonFactory {
        private static Singleston2 Instance = new Singleston2();
    }

    public static Singleston2 getInstance() {
        return SinglestonFactory.Instance;
    }

    public int getValue() {
        return value;
    }


}
